import {HANDLER_BLUR,HANDLER_FOUCS,GET_LIST,INIT_LIST_DATA,HANDLER_MOUSE_ENTER,HANDLER_MOUSE_LEAVE,CHANGE_PAGE,GET_HOME_List,RECEIVEHOMEDATA,LOADMOREDATA,RECEIVEMOREDATA,CHANGE_SHOW,GET_DETAIL_DATA,RECEIVE_DETAIL_DATA} from './actionTypes'
import {fromJS} from 'immutable'
import{HANDLER_CHANGE_USERNAME,HANDLER_CHANGE_PASSWORD,GET_LOGIN_DATA,RECEIVE_LOGIN_DATA} from './actionTypes'
import { from } from 'rxjs';
export const getHandlerFoucsAction=()=>{
    return {
        type:HANDLER_FOUCS,
    }
}
export const getHandlerBlurAction=()=>{
    return {
        type:HANDLER_BLUR,
    }
}
export const getListAction =()=>{
    return{
        type:GET_LIST,
    }
}
export const getListDataAction =(data,length)=>{
    return{
        type:INIT_LIST_DATA,
        data:fromJS(data),
        length:fromJS(length),
    }
}
export const getHandlerMouseEnter = () =>{
    return{
        type:HANDLER_MOUSE_ENTER,
    }
}
export const getHandlerMouseLeave = () =>{
    return{
        type:HANDLER_MOUSE_LEAVE,
    }
}
export const getHandlerChangePage = (page) =>{
    return{
        type:CHANGE_PAGE,
        page:fromJS(page),
    }
}
export const getHomeData=()=>{
    return{
        type:GET_HOME_List,
    }
}
// 需要转化为immutable对象再发送到reducer中
export const receiveHomeData=(topiclist,contentlist,recommendlist,writinglist)=>{
    return{
        type:RECEIVEHOMEDATA,
        topiclist:fromJS(topiclist),
        contentlist:fromJS(contentlist),
        recommendlist:fromJS(recommendlist),
        writinglist:fromJS(writinglist),
    }
}
export const loadMoreAction = ()=>{
    return{
        type:LOADMOREDATA,
    }
}
export const receiveMoreData=(data)=>{
    return{
        type:RECEIVEMOREDATA,
        data:fromJS(data),
    }
}
export const changeShow = (show)=>{
    return{
        type:CHANGE_SHOW,
        show:fromJS(show),
    }
}
export const getDetailAction = ()=>{
    return{
        type:GET_DETAIL_DATA,
    }
}
export const receiveDetailAction = (data)=>{
    return{
        type:RECEIVE_DETAIL_DATA,
        data:fromJS(data),
    }
}
export const handlerUsernameChange = (data)=>{
    return{
        type:HANDLER_CHANGE_USERNAME,
        data:data
    }
}
export const handlerPasswordChange = (data)=>{
    return{
        type:HANDLER_CHANGE_PASSWORD,
        data:data
    }
}
export const getLoginAction = (username,password) =>{
    return{
        type:GET_LOGIN_DATA,
        username:username,
        password:password,
    }
}
export const receiveLoginAction = (success)=>{
    return{
        type:RECEIVE_LOGIN_DATA,
        success
    }
}